import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';
import Vue from 'vue'
import axios from 'axios'

import VueParticles from 'vue-particles'
Vue.use(VueParticles)
import VueAxios from 'vue-axios'
import utils from "@/api/utils";
let myid = utils.uuid();
if (sessionStorage.getItem("uuid") == null) {
  sessionStorage.setItem("uuid", myid);
}


import uploader from 'vue-simple-uploader'
Vue.use(uploader)
import BaiduMap from 'vue-baidu-map'

Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: 'YOUR_APP_KEY'
})
Vue.use(VueAxios, axios)
Vue.use(ElementUI);
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

Vue.use(ElementUI);


// Add a request interceptor
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  let token=localStorage.getItem("token");
  if(token){
    config.headers.token=token;
  }

  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
  // Do something with response data
  if(response.data.code=="401"){
    alert(1)
    localStorage.removeItem("token");
    location.href="/";
  }
  return response;
}, function (error) {
  // Do something with response error
  return Promise.reject(error);
});

